//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package test.StringPractise;

import java.util.Random;

public class StringPrecatiseSeven {
    public StringPrecatiseSeven() {
    }

    public static void main(String[] args) {
        System.out.println(demo("034861"));
        System.out.println(demo2("12345", "34512"));
        System.out.println(demo3("34226243"));
        System.out.println(demo4("hello world!"));
    }

    public static String demo(String s) {
        StringBuilder sb = new StringBuilder();

        for(int i = 0; i < s.length(); ++i) {
            switch (s.charAt(i)) {
                case '0':
                    sb.append("");
                    break;
                case '1':
                    sb.append("Ⅰ");
                    break;
                case '2':
                    sb.append("Ⅱ");
                    break;
                case '3':
                    sb.append("Ⅲ");
                    break;
                case '4':
                    sb.append("Ⅳ");
                    break;
                case '5':
                    sb.append("Ⅴ");
                    break;
                case '6':
                    sb.append("Ⅵ");
                    break;
                case '7':
                    sb.append("Ⅶ");
                    break;
                case '8':
                    sb.append("Ⅷ");
                    break;
                case '9':
                    sb.append("Ⅸ");
            }
        }

        return sb.toString();
    }

    public static boolean demo2(String A, String B) {
        StringBuilder sb = new StringBuilder(A);

        for(int i = 0; i < A.length(); ++i) {
            if (B.contentEquals(sb)) {
                return true;
            }

            sb.append(A.charAt(i)).deleteCharAt(0);
        }

        return false;
    }

    public static String demo3(String s) {
        char[] chars = s.toCharArray();
        Random rm = new Random();

        for(int i = 0; i < chars.length; ++i) {
            int r = rm.nextInt(chars.length);
            char t = chars[i];
            chars[i] = chars[r];
            chars[r] = t;
        }

        return new String(chars);
    }

    public static int demo4(String s) {
        int count = 0;

        for(int i = s.length() - 1; i > 0; --i) {
            if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z' || s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') {
                ++count;
            }

            if (count != 0 && s.charAt(i) == ' ') {
                break;
            }
        }

        return count;
    }
}
